﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Security;
namespace Lxzhu.OpenGL
{
    public partial class Gl
    {
        [DllImport(GlDll,CallingConvention=GlCalling ),SuppressUnmanagedCodeSecurity]
        public static extern void glEnableClientState(ArrayType at);
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glDisableClientState(ArrayType at);
        #region 指定数组数据
        [DllImport(GlDll,CallingConvention=GlCalling),SuppressUnmanagedCodeSecurity]
        public static extern void glVertexPointer(ArrayUnit size, DataType type, int stride, object[] ptr);
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glColorPointer(ArrayUnit size, DataType type, int stride, object[] ptr);
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glSecondaryColorPointer(ArrayUnit size, DataType type, int stride, object[] ptr);
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glIndexPointer(DataType type, int stride, object[] ptr);
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glNormalPointer(DataType type, int stride, object[] ptr);
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glFogCoordPointer(DataType type, int stride, object[] ptr);
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glTexCoordPointer(ArrayUnit size, DataType type, int stride, object[] ptr);
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glEdgeFlagPointer(int stride, bool[] ptr);
        #endregion
        #region glArrayElement
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glArrayElement(int ith);
        #endregion
        #region glDrawElements
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glDrawElements(PrimitiveType mode, int count, DataType type, byte[] indices);
        public static void glDrawElements(PrimitiveType mode, int count, byte[] indices)
        {
            glDrawElements(mode, count, DataType.Gl_UNSIGNED_BYTE, indices);
        }
        public static  void glDrawElements(PrimitiveType mode, byte[] indices)
        {
            glDrawElements(mode, indices.Length, DataType.Gl_UNSIGNED_BYTE, indices);
        }
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glDrawElements(PrimitiveType mode, int count, DataType type, short[] indices);
        public static void glDrawElements(PrimitiveType mode, int count, short[] indices)
        {
            glDrawElements(mode, count, DataType.GL_UNSIGNED_SHORT, indices);
        }
        public static void glDrawElements(PrimitiveType mode, short[] indices)
        {
            glDrawElements(mode, indices.Length, DataType.GL_UNSIGNED_SHORT, indices);
        }
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glDrawElements(PrimitiveType mode, int count, DataType type, int[] indices);
        public static void glDrawElements(PrimitiveType mode, int count, int[] indices)
        {
            glDrawElements(mode, count, DataType.GL_UNSIGNED_INT, indices);
        }
        public static void glDrawElements(PrimitiveType mode, int[] indices)
        {
            glDrawElements(mode, indices.Length, DataType.GL_UNSIGNED_INT, indices);
        }
        #endregion
        #region glMultiDrawElements
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glMultiDrawElements(PrimitiveType mode, int[] count, DataType type, byte[][] indices, int pricount);
        public static  void glMultiDrawElements(PrimitiveType mode, int pricount, byte[][] indices)
        {
            int[] count = new int[pricount];
            for (int i = 0; i < pricount; i++)
                count[i] = (indices[i].Length);
            glMultiDrawElements(mode, count, pricount, indices);
        }
        public static  void glMultiDrawElements(PrimitiveType mode, int[] count, int pricount, byte[][] indices)
        {
            glMultiDrawElements(mode, count, DataType.Gl_UNSIGNED_BYTE, indices, pricount);
        }

        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glMultiDrawElements(PrimitiveType mode, int[] count, DataType type, short[][] indices, int pricount);
        public static  void glMultiDrawElements(PrimitiveType mode, int pricount, short[][] indices)
        {
            int[] count = new int[pricount];
            for (int i = 0; i < pricount; i++)
                count[i] = (indices[i].Length);
            glMultiDrawElements(mode, count, pricount, indices);
        }
        public static  void glMultiDrawElements(PrimitiveType mode, int[] count, int pricount, short[][] indices)
        {
            glMultiDrawElements(mode, count, DataType.GL_UNSIGNED_SHORT, indices, pricount);
        }

        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glMultiDrawElements(PrimitiveType mode, int[] count, DataType type, int[][] indices, int pricount);
        public static  void glMultiDrawElements(PrimitiveType mode, int pricount, int[][] indices)
        {
            int[] count = new int[pricount];
            for (int i = 0; i < pricount; i++)
                count[i] = (indices[i].Length);
            glMultiDrawElements(mode, count, pricount, indices);
        }
        public static  void glMultiDrawElements(PrimitiveType mode, int[] count, int pricount, int[][] indices)
        {
            glMultiDrawElements(mode, count, DataType.GL_UNSIGNED_INT, indices, pricount);
        }
        #endregion
        #region glDrawRangeElements
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glDrawRangeElements(PrimitiveType mode,int start,int end, int[] count, DataType type, byte[][] indices, int pricount);
        public static  void glDrawRangeElements(PrimitiveType mode, int start, int end, int pricount, byte[][] indices)
        {
            int[] count = new int[pricount];
            for (int i = 0; i < pricount; i++)
                count[i] = (indices[i].Length);
            glDrawRangeElements(mode, start, end, count, pricount, indices);
        }
        public static  void glDrawRangeElements(PrimitiveType mode, int start, int end, int[] count, int pricount, byte[][] indices)
        {
            glDrawRangeElements(mode, start, end, count, DataType.Gl_UNSIGNED_BYTE, indices, pricount);
        }

        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glDrawRangeElements(PrimitiveType mode, int start, int end, int[] count, DataType type, short[][] indices, int pricount);
        public static  void glDrawRangeElements(PrimitiveType mode, int start, int end, int pricount, short[][] indices)
        {
            int[] count = new int[pricount];
            for (int i = 0; i < pricount; i++)
                count[i] = (indices[i].Length);
            glDrawRangeElements(mode, start, end, count, pricount, indices);
        }
        public static  void glDrawRangeElements(PrimitiveType mode, int start, int end, int[] count, int pricount, short[][] indices)
        {
            glDrawRangeElements(mode, start, end, count, DataType.GL_UNSIGNED_SHORT, indices, pricount);
        }

        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glDrawRangeElements(PrimitiveType mode, int start, int end, int[] count, DataType type, int[][] indices, int pricount);
        public static  void glDrawRangeElements(PrimitiveType mode, int start, int end, int pricount, int[][] indices)
        {
            int[] count = new int[pricount];
            for (int i = 0; i < pricount; i++)
                count[i] = (indices[i].Length);
            glDrawRangeElements(mode, start, end, count, pricount, indices);
        }
        public static  void glDrawRangeElements(PrimitiveType mode, int start, int end, int[] count, int pricount, int[][] indices)
        {
            glDrawRangeElements(mode, start,end,count, DataType.GL_UNSIGNED_INT, indices, pricount);
        }
        #endregion
        #region glDrawArrays
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glDrawArrays(PrimitiveType mode, int first, int count);
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glMultiDrawArrays(PrimitiveType mode, int[] first, int[] count, int pricount);
        public static  void glMultiDrawArrays(PrimitiveType mode, int[] first, int[] count)
        {
            int pricount = first.Length < count.Length ? first.Length : count.Length;
            glMultiDrawArrays(mode, first, count, pricount);
        }
        #endregion
        #region 混合数组glInterleavedArrays
        /// <summary>
        /// 这个函数的使用效果还没搞懂.
        /// </summary>
        /// <param name="format"></param>
        /// <param name="stride"></param>
        /// <param name="ptr"></param>
        [DllImport(GlDll, CallingConvention = GlCalling), SuppressUnmanagedCodeSecurity]
        public static extern void glInterleavedArrays(InterleavedFormat format, int stride, byte[] ptr);
        #endregion
    }
}
